package com.central.scheduler.dao.mapper;

import com.central.db.mapper.SuperMapper;
import com.central.scheduler.common.enums.AlertStatus;
import com.central.scheduler.dao.model.Alert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
/**
 * @author Tindy
 * @date 2021/11/5
 * @describe alert mapper interface
 */
@Mapper
public interface AlertMapper extends SuperMapper<Alert> {

    /**
     * list alert by status
     * @param alertStatus alertStatus
     * @return alert list
     */
    List<Alert> listAlertByStatus(@Param("alertStatus") AlertStatus alertStatus);

    /**
     * Insert server crash alert
     * <p>This method will ensure that there is at most one unsent alert which has the same content in the database.
     */
    void insertAlertWhenServerCrash(@Param("alert") Alert alert);

}
